<template>
  <dt-modal-edit
    ref="edit"
    :title="title"
    :loading="loading"
    :label-width="130"
    okText="确认"
    :width="600"
    @ok="onOk"></dt-modal-edit>
</template>

<script>
  import editOpt from '../opt/edit'
  import pointMgr from '@/biz/customerForCode/point'

  export default {
    components: {},
    data() {
      return {
        loading: false,
        title: '新建/编辑点位',
        info: {},
        isEdit: false,
        isActivity: false
      }
    },
    methods: {
      show(data) {
        this.isEdit = data.isEdit
        this.isActivity = data.isActivity
        this.title = data.title
        this.info = data
        this.$refs.edit.show()
        this.$refs.edit.show(editOpt.pointPositionOpt(this), this.info)
      },
      updateOpt() {
        this.$refs.edit.show(editOpt.pointPositionOpt(this), this.info)
      },
      onOk(data) {
        let params = {
          pointPositionName: data.pointPositionName,
          activityId: this.$route.query.activityId,
          activityType: this.isActivity ? 2 : 1,
          id: data.id,
          tokerId: data.tokerId
        }
        pointMgr.createPoint(params).then((res) => {
          this.$Message.success('保存成功')
          this.$emit('success')
          this.$refs.edit.hide()
        })
      }
    }
  }
</script>

<style lang="scss" scoped></style>
